From: Julien Grall Date: Fri, 22 Apr 2016 15:58:32 +0000 (+0100) Subject: xen/bitops: Introduce GENMASK to generate mask X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1226 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=edd429c9cc2af99df9dda10002cc59011edf0cac;p=xen.git xen/bitops: Introduce GENMASK to generate mask The code has been imported from the header include/linux/bitops.h in Linux v4.6-rc3. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index cb56f247ab..bd0883ab22 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -2,6 +2,14 @@ #define _LINUX_BITOPS_H #include +/* + * Create a contiguous bitmask starting at bit position @l and ending at + * position @h. For example + * GENMASK(30, 21) gives us the 32bit vector 0x01fe00000. + */ +#define GENMASK(h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + /* * ffs: find first bit set. This is defined the same way as * the libc and compiler builtin ffs routines, therefore